package com.cyou.qb.face.log.impl;

import java.util.Date;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import com.cyou.qb.face.entity.Face173AccessLog;
import com.cyou.qb.face.entity.OutService;
import com.cyou.qb.face.log.IOutServiceLog;
/**
 * <p>调用173接口出现错误时将错误OutService写入到数据库中,将切面出日志插入到mongoDB中</p>
 * @author wangwenlong
 *
 */
public class OutServiceFailLogImpl implements IOutServiceLog{

//	@Autowired
	private JdbcTemplate jdbcTemplate;
	
	Logger logger = Logger.getLogger(OutServiceFailLogImpl.class);
//	@Override
	public void saveOutServiceFail(OutService outService) {
		String sql = "INSERT INTO t_outservice_fail_log(call_service,target_object,target_type,memo,op_method,create_date) VALUES(?,?,?,?,?,?)";

		jdbcTemplate.update(sql,new Object[] { outService.getService(), outService.getObject(),
											   outService.getType(), outService.getMemo(),
											   outService.getMethod(), new Date()});
	}
	//FIXME 为accessLog方法重写toString方法
	@Override
	public void aspectLogProcess(Face173AccessLog accessLog) {
		logger.info("aspectProcessLog :" + accessLog);
	}
	@Override
	public void getReturnLog(String returnLog) {
		logger.info("InterFaceReturnLog result:" + returnLog);
	}
}
